import { SearchOutlined } from '@ant-design/icons'
import { Input, Table, TableColumnsType } from 'antd'
import '../XunJiaDanGuanLi/AllXunDan.scss'
import { useState } from 'react'
import { RowSelectionType } from 'antd/es/table/interface'
import { useNavigate } from 'react-router-dom'
const total = 281

interface DataType {
    id: number,
    orderId: string,
    downTime: string,
    ordersId: string,
    status: number,
    beforeTime: string,
    afterTime: string,
    leftOver: string,
    rightOver: string,
    getgood: string,
    price: number,
    goods: string,
    weight: number,
    overTime: string,
}



export default function AllDingDan() {
    const columns: TableColumnsType<DataType> = [
        {
            title: '订单号',
            dataIndex: 'orderId',
            render: (text: string) => <a onClick={()=>navigate('/')}>{text}</a>,
        },
        {
            title: '下单时间',
            dataIndex: 'downTime',
        },
        {
            title: '合同编号',
            dataIndex: 'ordersId',
            render: (text: string) => <a>{text}</a>,
        },
        {
            title: '状态',
            dataIndex: 'status',
            render: (text: number) => <span>{text == 1 ? '待审核' : text == 2 ? '已报价' : text == 3 ? "已拒绝" : '已过期'
    
            }</span>,
        },
        {
            title: '计划发车时间',
            dataIndex: 'beforeTime',
        },
        {
            title: '计划到达时间',
            dataIndex: 'afterTime',
        },
        {
            title: '始发地',
            dataIndex: 'leftOver',
        },
        {
            title: '目的地',
            dataIndex: 'rightOver',
        },
        {
            title: '收货方',
            dataIndex: 'getgood',
        },
        {
            title: '货物名称',
            dataIndex: 'goods',
        },
        {
            title: '重量(kg)',
            dataIndex: 'weight',
        },
        {
            title: '运输费(￥)',
            dataIndex: 'price',
        },
        {
            title: '报价有效截止日期',
            dataIndex: 'overTime',
        },
    ];
    
    const data: DataType[] = [
        {
            id: 1,
            orderId: 'XL00000001',
            downTime: '2024/09/10 09:12:59',
            ordersId: 'HCF2024016514',
            status: 1,
            beforeTime: '2024/09/10 09:12:59',
            afterTime: '2024/10/10 09:12:59',
            leftOver: "青岛市",
            rightOver: '天津市',
            getgood: '天津科技公司',
            price: 19999,
            goods: '白糖精糖',
            weight: 50,
            overTime: "2024/10/15 09:12:59"
        },
        {
            id: 2,
            orderId: 'XL00000002',
            downTime: '2024/09/10 09:12:59',
            ordersId: 'HCF2024066876',
            status: 2,
            beforeTime: '2024/09/10 09:12:59',
            afterTime: '2024/10/10 09:12:59',
            leftOver: "青岛市",
            rightOver: '天津市',
            getgood: '天津科技公司',
            price: 19999,
            goods: '木头',
            weight: 50,
            overTime: "2024/10/15 09:12:59"
        },
        {
            id: 3,
            orderId: 'XL00000003',
            downTime: '2024/09/10 09:12:59',
            ordersId: 'HCF2024016557',
            status: 1,
            beforeTime: '2024/09/10 09:12:59',
            afterTime: '2024/10/10 09:12:59',
            leftOver: "青岛市",
            rightOver: '天津市',
            getgood: '天津科技公司',
            price: 19999,
            goods: '精糖',
            weight: 50,
            overTime: "2024/10/15 09:12:59"
        },
        {
            id: 4,
            orderId: 'XL00000004',
            downTime: '2024/09/10 09:12:59',
            ordersId: 'HCF2024065677',
            status: 3,
            beforeTime: '2024/09/10 09:12:59',
            afterTime: '2024/10/10 09:12:59',
            leftOver: "青岛市",
            rightOver: '天津市',
            getgood: '天津科技公司',
            price: 19999,
            goods: '水果',
            weight: 50,
            overTime: "2024/10/15 09:12:59"
        },
    ];
    const selectionType: RowSelectionType = 'radio'
    const navigate = useNavigate();
    return (
        <div className='AllXunDan'>
            <div>
                <div className='title_search'>
                    <span className='text_total'>共{total}条</span>
                    <Input className='search' placeholder="请输入关键词" variant="borderless" prefix={<SearchOutlined />} />
                </div>

            </div>
            <div className='table_container'>
                <Table<DataType>
                    rowKey="id"
                    scroll={{ x: 2000 }}
                    className="custom-table"
                    rowSelection={{ type: selectionType, defaultSelectedRowKeys: [1] }}
                    columns={columns}
                    dataSource={data}
                />
            </div>
        </div>
    )
}
